<template>
  <div id="register-box">
      <div>
        <label>账号：</label><input type="text" placeholder="输入你想使用的账号" v-model="name"><br>
        <label>密码：</label><input type="password" placeholder="输入你想设置的密码" v-model="password">
      </div>
      <div>
        <input type="radio" name="type" value="用户" v-model="type"><label>用户注册</label>
        <input type="radio" name="type" value="商家" v-model="type"><label>商家注册</label>
      
    </div>
      <div>
        <button @click="registerA">确认注册</button>
      </div>
  </div>
</template>

<script>
import {request} from '../../network/request';
import { createNamespacedHelpers } from "vuex";
const { mapState, mapActions } = createNamespacedHelpers("login");
export default {
    data() {
      return {
        name:'',
        password:'',
        type:'用户',
        ice:true
      }
    },

    methods: { 
       ...mapActions(['register']),
     async registerA(){
      const data =await  this.register({name:this.name,password:this.password,type:this.type,ice:this.ice});
   
      if(data.success){
     this.$router.push('/login')
      }
      }
    },
}
</script>

<style>
#register-box{
       width: 400px;
     height: 200px;
     border: 1px solid #ccc;
     margin: 100px auto;
}
</style>